<?php 

Yii::app()->clientScript->registerCssFile('css/InvoiceReport.css'); 
?>
<div id="invoice-report">
    <div id="create-date">
        <?php echo date('Y-m-d'); ?>
        <br/>
        <?php echo date('H:i:s'); ?>
    </div>

    <div id="title">
        <b>Sales Order Report</b>
        <br/>
        
    </div>
    <div class="details">
    <div class="start-date">Start Date <?php echo $model->startDate; ?></div>
        <div class="end-date">End Date <?php echo $model->endDate; ?></div>
        <div class="type">Status <?php echo $model->status == '' ? 'All' : $model->status; ?></div>        
        </div>
    <div id="content">
        <?php
        $table = new CI_Table();
        $table->set_template(array(
            'table_open'=>'<table class="zeebra">'
        ));
        $table->set_heading('Type', 'Sales Order No', 'Reference', 'Date','Status', 'Total');
        $total = 0;
        $dataList=$model->getData();
        foreach ($dataList as $invoice) {
            /* @var $invoice Invoice */
            $reference = $invoice->quoteorg != NULL ? $invoice->quoteorg : $invoice->salesordersorg;
            $table->add_row(
                    $invoice->invoicetype, 
                    CHtml::link($invoice->invoice, array('invoices/update', 'invoice' => $invoice->invoice)), 
                    CHtml::link($reference, array('invoices/update', 'invoice' => $reference)), 
                    $invoice->invoicedate, 
                    JobsStatus::getText($invoice->salesorderstatus),
                    $invoice->amountcharge
            );
            $total+=$invoice->amountcharge;
        }
        echo $table->generate();
        ?>

    </div>

    <br/>
   
    <div id="total">Total <?php echo number_format($total, 2); ?></div>


</div>